package com.ruoyi.applet.service.impl;

import java.util.List;

import com.ruoyi.applet.domain.ProductSpecs;
import com.ruoyi.applet.domain.vo.CartVo;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.applet.mapper.CartMapper;
import com.ruoyi.applet.domain.Cart;
import com.ruoyi.applet.service.ICartService;

import javax.annotation.Resource;

/**
 * 购物车Service业务层处理
 * 
 * @author ruoyi
 * @date 2024-12-04
 */
@Service
public class CartServiceImpl implements ICartService 
{
    @Resource
    private CartMapper cartMapper;

    /**
     * 查询购物车
     * 
     * @param cartId 购物车主键
     * @return 购物车
     */
    @Override
    public Cart selectCartByCartId(Long cartId)
    {
        return cartMapper.selectCartByCartId(cartId);
    }

    /**
     * 查询购物车列表
     * 
     * @param usrId 购物车
     * @return 购物车
     */
    @Override
    public List<CartVo> selectCartList(Long usrId)
    {
        return cartMapper.selectCartList(usrId);
    }

    /**
     * 新增购物车
     * @return 结果
     */
    @Override
    public int insertCart( Long goodsId, Long userId ,Long buyNum,  Long proSpescId)
    {
        return cartMapper.insertCart(goodsId, userId, buyNum, proSpescId);
    }

    /**
     * 修改购物车
     * 
     * @param cart 购物车
     * @return 结果
     */
    @Override
    public int updateCart(Cart cart)
    {
        return cartMapper.updateCart(cart);
    }

    /**
     * 批量删除购物车
     * 
     * @param cartIds 需要删除的购物车主键
     * @return 结果
     */
    @Override
    public int deleteCartByCartIds(Long[] cartIds)
    {
        return cartMapper.deleteCartByCartIds(cartIds);
    }

    /**
     * 删除购物车信息
     * 
     * @param cartId 购物车主键
     * @return 结果
     */
    @Override
    public int deleteCartByCartId(Long cartId)
    {
        return cartMapper.deleteCartByCartId(cartId);
    }

    @Override
    public Boolean deleteByCartIdBoolean(Long cartId) {
        return cartMapper.deleteByCartIdBoolean(cartId);
    }

    @Override
    public Boolean updateCartIdBoolean(Long cartId, String isChecked) {
        return cartMapper.updateCartIdBoolean(cartId, isChecked);
    }

    @Override
    public Integer selectAllByProductSpecIdInteger(Long productSpecId) {
        return cartMapper.selectAllByProductSpecIdInteger(productSpecId);
    }

    @Override
    public Boolean updateProSpescIdBoolean(Long productSpecId, Long buyNum, Long usrId) {
        return cartMapper.updateProSpescIdBoolean(productSpecId, buyNum, usrId);
    }

    @Override
    public Cart selectByUserIdCart(Long productSpecId, Long usrId) {
        return cartMapper.selectByUserIdCart(productSpecId, usrId);
    }

    @Override
    public ProductSpecs selectAllByProductSpecId(Long productSpecId) {
        return cartMapper.selectAllByProductSpecId(productSpecId);
    }

    @Override
    public Integer updateIsCheckedAndBuyNumInteger(Long usrId, Long cartId, String isCheckEd, Long buyNum) {
        return cartMapper.updateIsCheckedAndBuyNumInteger(usrId, cartId, isCheckEd, buyNum);
    }
}
